import TopicCreateForm from "@/components/topics/topic-create-form";
import TopicList from "@/components/topic-list";
import { prisma } from "@/prisma";
import { fetchTopPosts } from "@/prisma/queries/posts";
import PostList from "@/components/posts/posts-list";
export default async function Page() {
  const topics = await prisma.topic.findMany({
    include: {
      _count: {
        select: {
          posts: true,
        },
      },
    },
  });
  const topPosts = await fetchTopPosts();
  return (
    <div className="flex justify-between">
      <div>
        <h1 className="text-xl m-2">Top Posts</h1>
        <PostList posts={topPosts} />
      </div>
      <div>
        <TopicCreateForm />
        <TopicList topics={topics} />
      </div>
    </div>
  );
}
